﻿namespace UIAStudio
{
    using MS.Internal.Mita.Foundation;
    using MS.Internal.Mita.Foundation.Utilities;
    using System;
    using System.Drawing;
    using System.Threading;

    public class HighlightWorkItem : WorkItem
    {
        private static MS.Internal.Mita.Foundation.Utilities.Highlighter _highlighter;
        private UIObject _uiObject;

        public HighlightWorkItem(WorkQueue queue, UIObject uiObject)
            : base(queue)
        {
            this._uiObject = uiObject;
        }

        protected override void Dispose(bool disposing)
        {
            this._uiObject = null;
            base.Dispose(disposing);
        }

        public override void Execute()
        {
            Rectangle rectangle;
            rectangle = this._uiObject.BoundingRectangle;
            ThreadStart simpleDelegate = delegate
            {
                Highlighter.Hide();
                Highlighter.SetLocation(rectangle);
                Highlighter.Show();
            };
            UIAStudio.MainForm.Instance.Invoke(simpleDelegate);
        }

        public static MS.Internal.Mita.Foundation.Utilities.Highlighter Highlighter
        {
            get
            {
                if (_highlighter == null)
                {
                    //HighlighterProperties.Default.Color = Settings.Instance.HighlightColor;
                    _highlighter = new MS.Internal.Mita.Foundation.Utilities.Highlighter();
                }
                return _highlighter;
            }
        }
    }
}

